package com.ctrip.demo.design.composite;

import java.util.ArrayList;
import java.util.List;

public class Menu {

    private Integer id;

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setChildren(List<Menu> children) {
        this.children = children;
    }

    public List<Menu> getChildren() {
        return children;
    }

    public Menu(String name, Integer id) {
        this.id = id;
        this.name = name;
    }

    private List<Menu> children = new ArrayList<>();

    void add(Menu menu) {
        children.add(menu);
    }

    void printMenu(Menu menu) {
        System.out.println(menu.id + "--" + menu.name);

        for (Menu menu1 : menu.children) {
            printMenu(menu1);
        }
    }
}
